package com.zk.atmp.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bpms.common.VO;
import com.bpms.servlet.BaseServlet;
import com.service.util.MD5Util;
import com.service.util.StringUtil;
import com.service.util.myMD5Util;

public class SignFilter extends HttpServlet implements Filter,
		javax.imageio.spi.ServiceRegistry.Filter {

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
         String sign_md5=StringUtil.getPropertyValue(request.getParameter("s"));
         VO args=new BaseServlet().getVo((HttpServletRequest) request, (HttpServletResponse) response);
	     String sign_strs=args.getAttr("m")+args.getAttr("r")+args.getAttr("t")+args.getAttr("u");
	     String sign=StringUtil.getPropertyValue(args.getAttr("s"));
	     String sign_convert_md5=myMD5Util.MD5(sign_strs);
	     if(sign_convert_md5.equals(sign)){
	    	 chain.doFilter(request, response);
	     }else{
	    	 com.bpms.common.DictValue dict;
	    	 //1 把监控状态写入到：dictvalue表
	    	 //2 把设备表中的子，p去掉。改写到设备类型：类型明细表中
//	    	 dict.
	     }
	}

	@Override
	public void init(FilterConfig config) throws ServletException {

	}

	@Override
	public boolean filter(Object provider) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}
	
}
